package com.yyi.springcloud.controller;

import com.yyi.springcloud.entities.GroupConfigModel;
import com.yyi.springcloud.service.Local_GroupConfigService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

//传感器分组
@Controller
@RequestMapping("/mysqlapi/GroupConfig")
public class Mysql_GroupConfigController {
	@Resource
	private Local_GroupConfigService groupConfigService;

	// 查询所有的传感器分组
	// http://localhost:8080/bxxs/api/GroupConfig/getAllGroup
	@ResponseBody
	@RequestMapping(value = "/getAllGroup", method = RequestMethod.GET)
	public List<GroupConfigModel> getAllGroup() {
		List<GroupConfigModel> list = groupConfigService.getAllGroup();
		return list;
	}

	// 根据LabCode查询传感器分组信息
	// http://localhost:8080/bxxs/mysqlapi/GroupConfig/getGroupConfigInfo
	@ResponseBody
	@RequestMapping(value = "/getGroupConfigInfo", method = RequestMethod.GET)
	public List<GroupConfigModel> getGroupConfigInfo(String labcode) {
		GroupConfigModel groupConfigModel=new GroupConfigModel();
		if(!StringUtils.isEmpty(labcode)){
			groupConfigModel.setLabcode(labcode);
		}
		List<GroupConfigModel> list = groupConfigService.getGroupConfigByCondition(groupConfigModel);
		return list;
	}
}
